package com.yushu.common.util.pager;

import com.yushu.common.util.pages.Page;

import java.io.Serializable;

public class Pages<T> extends Page<T> implements Serializable {
    private static final long serialVersionUID = 768549219446295665L;
    //信息
    private String msg;
    private String sort;
    private String order;


    // bootstrap 参数，每页显示多少条数据
    private int limit;

    //bootstrap 参数,开始计数的哪一条10，表示从第10条数据开始
    private int offset;
    private T data;

    public Pages() {
//        setRecords(getData());

    }
    public Pages(int current, int size) {
        super(current, size);

    }

    @Override
    public void setCurrent(int current) {
        super.setCurrent(getOffset() /getLimit() + 1);
    }

    @Override
    public void setSize(int size) {
        super.setSize(getLimit());
    }

    public int getLimit() {
        if (0 == limit) {
            return 10;
        } else {
            return limit;
        }

    }


    public void setLimit(int limit) {
        this.limit = limit;
    }


    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMsg() {
        return "共查询出" + getTotal() + "条数据!";
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }


    //成功与否
    private boolean success;

    //状态
    private Integer status;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public Integer getStatus() {
        return 0;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getSort() {
        return sort;
    }

    public void setSort(String sort) {
        this.sort = sort;
    }

    public String getOrder() {
        return order;
    }

    public void setOrder(String order) {
        this.order = order;
    }
}
